//
//  LGRecipeMedicineCell.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/3/4.
//

#import "LGRecipeMedicineCell.h"


@interface LGRecipeMedicineCell()
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *remarkLabel;

@end

@implementation LGRecipeMedicineCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.nameLabel.text = [NSString stringWithFormat:@"%@ , %@",dataDic[@"title"],dataDic[@"take_frequency"]];
    self.timeLabel.text = LGNSString(dataDic[@"take_method"]);
    NSString *remark = LGNSString(dataDic[@"remark"]);
    CGFloat remarkTop = (remark.length>0)?viewPix(8):0;
    [self.remarkLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.timeLabel.mas_bottom).offset(remarkTop);
    }];
    self.remarkLabel.text = remark;
}

-(void)createSubView{
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.remarkLabel];
    [self.contentView addSubview:self.lineView];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(5));
        make.left.equalTo(self.contentView).offset(viewPix(18));
        make.right.equalTo(self.contentView).offset(-viewPix(14));
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(viewPix(8));
        make.left.right.equalTo(self.nameLabel);
    }];
    [self.remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.timeLabel.mas_bottom).offset(viewPix(8));
        make.left.right.equalTo(self.nameLabel);
        make.bottom.equalTo(self.contentView).offset(-viewPix(12));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.nameLabel);
        make.bottom.equalTo(self.contentView).offset(-viewPix(5));
        make.height.equalTo(@(0.5));
    }];
    
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _nameLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _timeLabel;
}

-(UILabel *)remarkLabel{
    if(!_remarkLabel){
        _remarkLabel = [UILabel lableWithText:@"" colorString:@"#909399" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _remarkLabel;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
